home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 42 / Amiga Format AFCD42 (Issue 126, Aug 1999).iso / -serious- / programming / other / jikes / src / class.h < prev    next >
C/C++ Source or Header  |  1999-05-14  |  31KB  |  1,039 lines

  1. // $Id: class.h,v 1.5 1999/02/01 17:43:05 shields Exp $
  2. //
  3. // This software is subject to the terms of the IBM Jikes Compiler
  4. // License Agreement available at the following URL:
  5. // http://www.ibm.com/research/jikes.
  6. // Copyright (C) 1996, 1998, International Business Machines Corporation
  7. // and others.  All Rights Reserved.
  8. // You must accept the terms of that agreement to use this software.
  9. //
  10. #ifndef class_INCLUDED
  11. #define class_INCLUDED
  12.  
  13. #include "config.h"
  14. #include <stdio.h>
  15. #include "semantic.h"
  16. #include "access.h"
  17. #include "unicode.h"
  18. #include "tuple.h"
  19.  
  20. class cp_info
  21. {
  22. public:
  23.     u1 tag;
  24.  
  25.     cp_info(u1 _tag) : tag(_tag) {}
  26.  
  27.     virtual ~cp_info() {}
  28.  
  29.     virtual void put(OutputBuffer &output_buffer)
  30.     {
  31.          assert("trying to put unsupported attribute kind" == NULL);
  32.     }
  33.  
  34. #ifdef TEST
  35.     virtual void print(Tuple<cp_info *>& constant_pool) {
  36.         cout << (int) tag;
  37.     }
  38.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  39.         cout << (int) tag;
  40.     }
  41. #endif
  42. };
  43.  
  44.  
  45. class CONSTANT_Class_info : public cp_info
  46. {
  47. public:
  48.     /* u1 tag; */
  49.     u2 name_index;
  50.  
  51.     CONSTANT_Class_info(u1 _tag) : cp_info(_tag) {}
  52.     virtual ~CONSTANT_Class_info() {}
  53.  
  54.     virtual void put(OutputBuffer &output_buffer)
  55.     {
  56.         output_buffer.PutB1(tag);
  57.         output_buffer.PutB2(name_index);
  58.     }
  59.  
  60. #ifdef TEST
  61.     virtual void print(Tuple<cp_info *>& constant_pool) {
  62.         cout << "CONSTANT_Class_info: name_index " << name_index << "\n";
  63.     }
  64.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  65.         cout << "Class:";  constant_pool[name_index]->describe(constant_pool);
  66.     }
  67. #endif    
  68. };
  69.  
  70. class CONSTANT_Double_info : public cp_info
  71. {
  72. public:
  73.     /* u1 tag; */
  74.     u4 high_bytes;
  75.     u4 low_bytes;
  76.  
  77.     CONSTANT_Double_info(u1 _tag) : cp_info(_tag) {}
  78.     virtual ~CONSTANT_Double_info() {}
  79.  
  80.     virtual void put(OutputBuffer &output_buffer)
  81.     {
  82.         output_buffer.PutB1(tag);
  83.         output_buffer.PutB4(high_bytes);
  84.         output_buffer.PutB4(low_bytes);
  85.     }
  86.  
  87. #ifdef TEST
  88.     virtual void print(Tuple<cp_info *>& constant_pool) {
  89.         cout << "CONSTANT_Float_info: bytes  \n";
  90.     }
  91.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  92.         cout << "D:";
  93. //        constant_pool[string_index]->describe(constant_pool);
  94.     }
  95. #endif    
  96. };
  97.  
  98. class CONSTANT_Fieldref_info : public cp_info
  99. {
  100. public:
  101.     /* u1 tag; */
  102.     u2 class_index;
  103.     u2 name_and_type_index;
  104.  
  105.     CONSTANT_Fieldref_info(u1 _tag) : cp_info(_tag) {}
  106.     virtual ~CONSTANT_Fieldref_info() {}
  107.  
  108.     virtual void put(OutputBuffer &output_buffer)
  109.     {
  110.          output_buffer.PutB1(tag);
  111.          output_buffer.PutB2(class_index);
  112.          output_buffer.PutB2(name_and_type_index);
  113.     }
  114.  
  115. #ifdef TEST
  116.     virtual void print(Tuple<cp_info *>& constant_pool) {
  117.         cout << "CONSTANT_Fieldref_info: class_index: " << class_index
  118.              << ", name_and_type_index: " << name_and_type_index << "\n";
  119.     }
  120.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  121.         constant_pool[class_index]->describe(constant_pool); cout << ".";
  122.         constant_pool[name_and_type_index]->describe(constant_pool);
  123.     }
  124. #endif    
  125. };
  126.  
  127. class CONSTANT_Float_info : public cp_info
  128. {
  129. public:
  130.     /* u1 tag; */
  131.     u4 bytes;
  132.  
  133.     CONSTANT_Float_info(u1 _tag) : cp_info(_tag) {}
  134.     virtual ~CONSTANT_Float_info() {}
  135.  
  136.     virtual void put(OutputBuffer &output_buffer)
  137.     {
  138.         output_buffer.PutB1(tag);
  139.         output_buffer.PutB4(bytes);
  140.     }
  141.  
  142. #ifdef TEST
  143.     virtual void print(Tuple<cp_info *>& constant_pool) {
  144.         cout << "CONSTANT_Float_info: bytes " << (float) bytes << "\n"; //DSDouble
  145.     }
  146.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  147.         cout << "F:";
  148. //        constant_pool[string_index]->describe(constant_pool);
  149.     }
  150. #endif    
  151. };
  152.  
  153.  
  154. class CONSTANT_Integer_info : public cp_info
  155. {
  156. public:
  157.     /* u1 tag; */
  158.     u4 bytes;
  159.  
  160.     CONSTANT_Integer_info(u1 _tag) : cp_info(_tag) {}
  161.     virtual ~CONSTANT_Integer_info() {}
  162.  
  163.     virtual void put(OutputBuffer &output_buffer)
  164.     {
  165.         output_buffer.PutB1(tag);
  166.         output_buffer.PutB4(bytes);
  167.     }
  168.  
  169. #ifdef TEST
  170.     virtual void print(Tuple<cp_info *>& constant_pool) {
  171.     int val;
  172.     val = ((bytes>>24)&0xff)<<24 | ((bytes>>16)&0xff)<<16
  173.         | ((bytes>>8)&0xff)<<8 | (bytes&0xff);
  174. //        cout << "CONSTANT_Integer_info: bytes " <<  value << "\n";
  175.         cout << "CONSTANT_Integer_info: bytes " << val << "\n";
  176.     }
  177.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  178.         cout << "I:";
  179. //        constant_pool[string_index]->describe(constant_pool);
  180.     }
  181. #endif    
  182. };
  183.  
  184. class CONSTANT_InterfaceMethodref_info : public cp_info
  185. {
  186. public:
  187.     /* u1 tag; */
  188.     u2 class_index;
  189.     u2 name_and_type_index;
  190.  
  191.     CONSTANT_InterfaceMethodref_info(u1 _tag) : cp_info(_tag) {}
  192.     virtual ~CONSTANT_InterfaceMethodref_info() {}
  193.  
  194.     virtual void put(OutputBuffer &output_buffer)
  195.     {
  196.         output_buffer.PutB1(tag);
  197.         output_buffer.PutB2(class_index);
  198.         output_buffer.PutB2(name_and_type_index);
  199.     }
  200.  
  201. #ifdef TEST
  202.     virtual void print(Tuple<cp_info *>& constant_pool) {
  203.         cout << "CONSTANT_InterfaceMethodref_info: class_index: " << class_index
  204.              << ", name_and_type_index: " << name_and_type_index << "\n";
  205.     }
  206.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  207.         constant_pool[class_index]->describe(constant_pool); cout << ".";
  208.         constant_pool[name_and_type_index]->describe(constant_pool);
  209.     }
  210. #endif    
  211. };
  212.  
  213. class CONSTANT_Long_info : public cp_info
  214. {
  215. public:
  216.     /* u1 tag; */
  217.     u4 high_bytes;
  218.     u4 low_bytes;
  219.  
  220.     CONSTANT_Long_info(u1 _tag) : cp_info(_tag) {}
  221.     virtual ~CONSTANT_Long_info() {}
  222.  
  223.     virtual void put(OutputBuffer &output_buffer)
  224.     {
  225.         output_buffer.PutB1(tag);
  226.         output_buffer.PutB4(high_bytes);
  227.         output_buffer.PutB4(low_bytes);
  228.     }
  229.  
  230. #ifdef TEST
  231.     virtual void print(Tuple<cp_info *>& constant_pool) {
  232.         cout << "CONSTANT_Long_info: bytes \n";
  233.     }
  234.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  235.         cout << "L:";
  236. //        constant_pool[string_index]->describe(constant_pool);
  237.     }
  238. #endif    
  239. };
  240.  
  241. class CONSTANT_Methodref_info : public cp_info
  242. {
  243. public:
  244.     /* u1 tag; */
  245.     u2 class_index;
  246.     u2 name_and_type_index;
  247.  
  248.  
  249.     CONSTANT_Methodref_info(u1 _tag) : cp_info(_tag) {}
  250.     virtual ~CONSTANT_Methodref_info() {}
  251.  
  252.     virtual void put(OutputBuffer &output_buffer)
  253.     {
  254.         output_buffer.PutB1(tag);
  255.         output_buffer.PutB2(class_index);
  256.         output_buffer.PutB2(name_and_type_index);
  257.     }
  258.  
  259. #ifdef TEST
  260.     virtual void print(Tuple<cp_info *>& constant_pool) {
  261.         cout << "CONSTANT_Methodref_info: class_index: " << class_index
  262.              << ", name_and_type_index: " << name_and_type_index << "\n";
  263.     }
  264.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  265.         constant_pool[class_index]->describe(constant_pool); cout << ".";
  266.         constant_pool[name_and_type_index]->describe(constant_pool);
  267.     }
  268. #endif    
  269. };
  270.  
  271. class CONSTANT_NameAndType_info : public cp_info
  272. {
  273. public:
  274.     /* u1 tag; */
  275.     u2 name_index;
  276.     u2 descriptor_index;
  277.  
  278.     CONSTANT_NameAndType_info(u1 _tag) : cp_info(_tag) {}
  279.     virtual ~CONSTANT_NameAndType_info() {}
  280.  
  281.     virtual void put(OutputBuffer &output_buffer)
  282.     {
  283.         output_buffer.PutB1(tag);
  284.         output_buffer.PutB2(name_index);
  285.         output_buffer.PutB2(descriptor_index);
  286.     }
  287.  
  288. #ifdef TEST
  289.     virtual void print(Tuple<cp_info *>& constant_pool) {
  290.         cout << "CONSTANT_NameAndType_info: name_index: " << name_index
  291.              << ", descriptor_index: " << descriptor_index << "\n";
  292.     }
  293.     virtual void describe(Tuple<cp_info *>& constant_pool) {
  294.         constant_pool[name_index]->describe(constant_pool);
  295.         cout << " ";
  296.         constant_pool[descriptor_index]->describe(constant_pool);
  297.     }
  298. #endif    
  299. };
  300.  
  301. class CONSTANT_String_info : public cp_info
  302. {
  303. public:
  304.     /* u1 tag; */
  305.     u2 string_index;
  306.  
  307.     CONSTANT_String_info(u1 _tag) : cp_info(_tag) {}
  308.     virtual ~CONSTANT_String_info() {}
  309.  
  310.     virtual void put(OutputBuffer &output_buffer)
  311.     {
  312.         output_buffer.PutB1(tag);
  313.         output_